<%--
  Created by IntelliJ IDEA.
  User: DongZhengWei
  Date: 2018/12/4
  Time: 16:12
  系统字典新建编辑页面
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
	String _id=request.getParameter("_");
%>

<form id="dict_input_form" class="form-horizontal">
	<input type="hidden" id="keyId" name="keyId" value="${dict.id}" />

	<div class="form-group">
		<label class="col-md-3 control-label">字典名称</label>
		<div class="col-md-7">
			<input type="text" class="form-control" id="name" name="name" placeholder="字典名称" value="${dict.name}" />
		</div>
	</div>

	<div class="form-group">
		<label class="col-md-3 control-label">关键字</label>
		<div class="col-md-7">
			<input type="text" class="form-control" id="value" name="value" placeholder="关键字" value="${dict.value}" />
		</div>
	</div>

	<div class="form-group">
		<label class="col-md-3 control-label">描述信息</label>
		<div class="col-md-7">
			<input type="text" class="form-control" id="description" name="description" placeholder="描述信息" value="${dict.description}" />
		</div>
	</div>

</form>

<script>

	$(function(){
	    fn_dict_input_valid();
	});

	function fn_dict_input_valid(){
	    __init_validate("dict_input_form", {
	        rules : {
                name : {
                    required : true
                },
                value : {
                    required : true,
                    remote : {
                        url : "<%=path%>/main/dict/checkValue",
                        type : "POST",
                        delay : 500,
                        data : {
                            value : function(){
                                return $("#dict_input_form #value").val();
                            },
	                        keyId : function(){
                                return $("#dict_input_form #keyId").val();
	                        }
                        }
                    }
                }
	        },
		    messages : {
	            name : {
	                required : "请填写字典名称"
	            },
			    value : {
	                required : "请填写关键字",
				    remote : "此关键字已经被使用了"
			    }
		    }

	    })
	}

	//保存
	function fn_dict_dialog_save(callback){
	    if($("#dict_input_form").valid()){
	        __form_save("dict_input_form","<%=path%>/main/dict/save",function(data){
	            callback(data);
	        })
	    }else{
	        callback();
	    }
	}

</script>